<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
        


        <c:if test="${not empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">
            Estas conectado como: ${sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal.username}
            <br/><a  href="/logout" >Desconectar</a>
 </c:if>
 <c:if test="${empty sessionScope.SPRING_SECURITY_CONTEXT.authentication.principal}">           
  <nav>
        <ul>
                <li id="login">
                        <a id="login-trigger" href="#">Inicia sesion<span>▼</span></a>
                        <div id="login-content">
                            <form action="/login" method="get" name="login">
                                  <fieldset id="inputs">
                                      <input id="username"  name="username" placeholder="Nombre Usuario" required>
                                      <input id="password" type="password" name="Password" placeholder="Contraseña" required>
                                  </fieldset>
                                    <fieldset id="actions">
                                          <input type="submit" id="submit" value="Log in">
                                          <label><input type="checkbox" checked="checked"> Keep me signed in</label>
                                    </fieldset>
                             </form>
                        </div>
                </li>
                <li id="signup">
                        <a href="">Registrate</a>
                </li>
        </ul>
</nav>
  </c:if>

            
            <script type="text/javascript">

            $(document).ready(


            function(){
                $("#submit").click(
                function (event) {
                    $.getJSON(
                    "/login",
                    {
                        "username": $("#username").val(),
                        "password": $("#password").val()
                    },
                    function(str) {
                        if (str) {
                            alert(str);
                        }
                    }
                );
                }
            );
            }
        );
        </script>

  
       
